#ifndef __EPAPER_DRIVER_H_
#define __EPAPER_DRIVER_H_

#include "freertos/FreeRTOS.h"
#include "freertos/task.h" 

#include "driver/gpio.h"
#include "mcu_io_config.h"
#include "base_type.h"

/**
 * e-Paper GPIO
**/
#define EPD_RST_PIN     RST_Pin
#define EPD_DC_PIN      DC_Pin
#define EPD_CS_PIN      SPI_CS_Pin
#define EPD_BUSY_PIN    BUSY_Pin

// Display resolution
#define EPD_2IN9_V2_WIDTH       128
#define EPD_2IN9_V2_HEIGHT      296

/**
 * GPIO read and write
**/
#define DEV_Digital_Write(_pin, _value) gpio_set_level(_pin, _value)
#define DEV_Digital_Read(_pin)          gpio_get_level(_pin)

/**
 * delay x ms
**/
#define DEV_Delay_ms(__xms) vTaskDelay(__xms/portTICK_PERIOD_MS)

void DEV_SPI_WriteByte(UBYTE value);

int DEV_Module_Init(void);
void DEV_Module_Exit(void);



int EPD_init(void);

void EPD_2IN9_V2_Init(void);
void EPD_2IN9_V2_Clear(void);
void EPD_2IN9_V2_Display(UBYTE *Image);
void EPD_2IN9_V2_Display_Base(UBYTE *Image);
void EPD_2IN9_V2_Display_Partial(UBYTE *Image);
void EPD_2IN9_V2_Sleep(void);

#endif